var app = angular.module('myApp', []);

app.controller('updateSelfInfoController', function($scope,$http) {
    $scope.updateSelfInfo = function() {
    	var userId = $("#userId").val();
    	var username = $("#username").val();
    	var truename = $("#truename").val();
        var gender = $("input[name='gender']:checked").val();
        var phone = $("#phone").val();
    	var email = $("#email").val();
        var job = $("#job").val();

        var formdata = {
            userId : userId,
            username : username,
            truename : truename,
            gender : gender,
            phone : phone,
            email : email,
            job : job
        }

        console.log(formdata);

    	var url = $scope.getBasePath() + 'user/back_update';

        $.ajax({
            url : url,
            type : "POST",
            dataType : "json",
            timeout : 10000,
            success : function (data) {
                console.log("success");
                console.log(data);
                alert(data.msg);
                if (data.isSuccess) {
                    location.href = $scope.getBasePath() + "user/center";
                }
            },
            error : function (data) {
                console.log("error");
                console.log(data);
                console.log(typeof data);
            },
            data : formdata
        });
    }

    $scope.getBasePath = globalPath.getBasePath;
});